import { RootObject } from './types/rootObject'
import request from './request/requestToken'

// 采集管理
// 场景列表
export const sceneList = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-scene/page',
  data,
})

// 场景机构的可选设备列表
export const sceneEquipment = (id: any) => request<RootObject<any>>({
  method: 'GET',
  url: `/acq-equip/orgList/${id}`,
})

// 场景新增
export const addScene = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-scene/add',
  data,
})

// 场景编辑
export const editScene = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-scene/update',
  data,
})

// 场景详情
export const sceneDetail = (id: any) => request<RootObject<any>>({
  method: 'GET',
  url: `/acq-scene/detail/${id}`,
})

// 场景删除
export const dellScene = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-scene/delete',
  data,
})

// 设备列表
export const equipList = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-equip/page',
  data,
})

// 设备状态列表
export const equipStatusList = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-equip/queryPage',
  data,
})

// 组织下的网关列表
export const netList = (id: any) => request<RootObject<any>>({
  method: 'GET',
  url: `/acq-gateway/orgList/${id}`,
})

// 组织下的设备模板列表
export const tempList = (id: any) => request<RootObject<any>>({
  method: 'GET',
  url: `/acq-equip-template/orgList/${id}`,
})

// 设备新增
export const addEquip = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-equip/add',
  data,
})

// 设备编辑
export const editEquip = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-equip/update',
  data,
})

// 设备详情
export const equipDetail = (id: any) => request<RootObject<any>>({
  method: 'GET',
  url: `/acq-equip/detail/${id}`,
})

// 获取设备状态数量信息
export const getEquipStatus = () => request<RootObject<{
  faultCount: number
  offlineCount: number
  onlineCount: number
  totalCount: number
}>>({
  method: 'GET',
  url: '/acq-equip/getEquipStatus',
})

// 设备删除
export const dellEquip = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-equip/delete',
  data,
})

// 查询一个商户下的设备信息列表
export const getEquipListByTenantId = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-equip/selectByTenantId',
  data,
})


// 模板列表
export const templateList = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-equip-template/page',
  data,
})

// 模板新增
export const addTemplate = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-equip-template/add',
  data,
})

// 模板编辑
export const editTemplate = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-equip-template/update',
  data,
})

// 模板详情
export const templateDetail = (id: any) => request<RootObject<any>>({
  method: 'GET',
  url: `/acq-equip-template/detail/${id}`,
})

// 模板删除
export const dellTemplate = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-equip-template/delete',
  data,
})

// 变量新增
export const addVar = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-equip-variable/add',
  data,
})

// 变量编辑
export const editVar = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-equip-variable/update',
  data,
})

// 变量详情
export const varDetail = (id: any) => request<RootObject<any>>({
  method: 'GET',
  url: `/acq-equip-variable/detail/${id}`,
})

// 变量删除
export const dellVar = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-equip-variable/delete',
  data,
})

// 网关列表
export const gatewayList = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-gateway/page',
  data,
})

// 网关新增
export const addGateway = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-gateway/add',
  data,
})

// 网关编辑
export const editGateway = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-gateway/update',
  data,
})

// 网关详情
export const gatewayDetail = (id: any) => request<RootObject<any>>({
  method: 'GET',
  url: `/acq-gateway/detail/${id}`,
})

// 网关删除
export const dellGateway = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-gateway/delete',
  data,
})

// 机构的可选设备列表
export type equipOrgItem = {
  orgId: number;
  orgName: string;
  equipList: equipItem[]
}
export type equipItem = {
  id: number;
  equipName: string;
}
export const apiGetOrgEquipList = (orgId: string) => 
  request<RootObject<equipOrgItem[]>>({
    method: 'GET',
    url: `/acq-equip/orgList/${orgId}`
  })

// 属性详情查询 获取数据字典项集合
export const getDist = (code: any) =>
  request<RootObject<any>>({
    method: "GET",
    url: `/sys-dict/list/${code}`,
  });

// OTA升级
// 升级包列表
export const otaList = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-ota/page',
  data,
})

// 升级包新增
export const addOta = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-ota/add',
  data,
})

// 升级包删除
export const dellOta = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-ota/delete',
  data,
})

// 升级包更新
export const editOta = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-ota/update',
  data,
})

// 升级包详情
export const otaDetail = (id: any) => request<RootObject<any>>({
  method: 'GET',
  url: `/acq-ota/detail/${id}`,
})

// 分页-批次列表
export const otaBatchList = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-ota/pageBatch',
  data,
})

// 重试
export const otaRetry = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-ota/retry',
  data,
})

// 立即升级
export const otaUpgrade = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-ota/upgrade',
  data,
})

// 升级包-设备列表
export const otaEquipList = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-ota/pageEquip',
  data,
})

// 批量升级-设备列表
export const otaEquipListBatch = (params: any) => request<RootObject<any>>({
  method: 'GET',
  url: '/acq-ota/equipList',
  params,
})

// 批量升级
export const otaUpgradeBatch = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-ota/batchUpgrade',
  data,
})

// 远程配置
// 远程配置分页列表
export const remoteList = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-config/page',
  data,
})

// 查询项目目录里
export const getProjectList = () => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-project/getList',
})

// 查询可升级设备列表
export const getUpgradeEquipList = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-config/equip/list',
  data,
})


// 远程配置新增
export const addRemote = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-config/add',
  data,
})

// 远程配置详情
export const remoteDetail = (id: any) => request<RootObject<any>>({
  method: 'GET',
  url: `/acq-config/detail/${id}`,
})

// 远程配置编辑
export const editRemote = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-config/update',
  data,
})

// 远程配置重试
export const remoteRetry = (id: any) => request<RootObject<any>>({
  method: 'GET',
  url: `/acq-config/retry/${id}`,
})

// 远程配置删除
export const remoteDell = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: `/acq-config/delete`,
  data
})

// 远程配置设备配置明细列表
export const remoteConfigList = (data: any) => request<RootObject<any>>({
  method: 'POST',
  url: '/acq-config/equip/detail',
  data,
})
